<template>
  <div>
    <button @click="dialogVisible = true">show</button>
    <el-dialog title="提示" :visible.sync="dialogVisible" width="30%" 
    :close-on-click-modal="false" :before-close="handleClose">

      <div>
        <el-upload
          class="upload-demo"
          :action="baseUrl + 'api/v1/upload/file'"
          :file-list="fileList"
          list-type="picture"
        >
          <el-button size="small" type="primary">点击上传</el-button>
        </el-upload>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
export default {
  data() {
    return {
      dialogVisible: false,
      fileList: [

      ],
      baseUrl: ''
    }
  },
  watch: {
    fileList: {
      handler(e) {
        console.log('changed', e)
      },
      deep: true
    }
  },
  created() {
    this.baseUrl = process.env.VUE_APP_UPLOAD
  },
  mounted() {
    window.abcde = () => {
      this.fileList.push({
        name: 'KRIS',
        url: 'https://obs-user-test.obs.cn-east-3.myhuaweicloud.com:443/test_1681711077_rvM6NnqFKe.jpg'
      })
    }
  },
  methods: {
    handleClose() {
      this.dialogVisible = false
    }
  }
}
</script>
